package regexObject;

public class ObjectDemo {
    public static void main(String[] args) {
        String s1=new String("nihao");
        String s2=new String("nihao");
        //String 类重写了equals()来比较字符串内容是否相同
        System.out.println(s1.equals(s2));//true
        StringBuilder builder1=new StringBuilder("nihao");
        StringBuilder builder2=new StringBuilder("nihao");
        //StringBuilder类没有重写equals(),因此调用的还是Object类的equals()比较地址
        System.out.println(builder1.equals(builder2));//false
        //s1与builder1的类型不同，所以equals()一定是false
        System.out.println(s1.equals(builder1));//false
    }
}
